(function() {
    var topSwitch = {
        init: function(page, todoList) {
            this.page = page;
            this.todoList = todoList;
            this.arrowUp = true;
            this.text = '显示事项列表';
        },
        show: function() {
            var renderData = this.page.getRenderData();
            renderData.topSwitchDisplay = 'block';
        },
        hide: function() {
            var renderData = this.page.getRenderData();
            renderData.topSwitchDisplay = 'none';
        },
        setText: function(text) {
            this.text = text;
            var renderData = this.page.getRenderData();
            renderData.topSwitchText = text;
        },
        getText: function() {
            return this.text;
        },
        setTop: function(top) {
            this.top = top;
            var renderData = this.page.getRenderData();
            renderData.topSwitchTop = top;
        },
        setHeight: function(height) {
            this.height = height;
            var renderData = this.page.getRenderData();
            renderData.topSwitchHeight = height;
        },
        upArrow: function() {
            if (this.arrowUp) {
                return;
            }
            this.arrowUp = true;
            var animation = wx.createAnimation({duration:180, timingFunction:'ease-in-out'});
            animation.rotate(0).step();
            var renderData = this.page.getRenderData();
            renderData.topSwitchArrowAnimation = animation.export();
        },
        downArrow: function() {
            if (!this.arrowUp) {
                return;
            }
            this.arrowUp = false;
            var animation = wx.createAnimation({duration:180, timingFunction:'ease-in-out'});
            animation.rotate(180).step();
            var renderData = this.page.getRenderData();
            renderData.topSwitchArrowAnimation = animation.export();
            console.log(renderData)
        }
    };

    function createTopSwitch() {
        return Object.create(topSwitch);
    }

    module.exports = {
        createTopSwitch:createTopSwitch
    }
})();